{*
 *  @author xuanhoapro <xuanhoapro@gmail.com>
 *  @version  1.0
 *  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 *
 *}
 <form  method="post" action="../dump.php">
	<div id="uploader">
		<p>Your browser doesn't have Flash, Silverlight, Gears, BrowserPlus or HTML5 support.</p>
	</div>
</form>
<script type="text/javascript">
{literal}    
// Convert divs to queue widgets when the DOM is ready
$(function() {
	$("#uploader").plupload({
		// General settings
		runtimes : 'flash,html5,browserplus,silverlight,gears,html4',
		url : '{/literal}{$_path}{literal}upload.php',
		max_file_size : '10mb',
		max_file_count: 20, // user can add no more then 20 files at a time
		chunk_size : '1mb',
		rename: true,
		multiple_queues : true,

		// Resize images on clientside if we can
		resize : {width : 320, height : 240, quality : 90},
		
		// Rename files by clicking on their titles
		rename: true,
		
		// Sort files
		sortable: true,

		// Specify what files to browse for
		filters : [
			{title : "Image files", extensions : "jpg"},
			{title : "Document files", extensions : "doc"}
		],

		// Flash settings
		flash_swf_url : '{/literal}{$_path}{literal}js/plupload.flash.swf',

		// Silverlight settings
		silverlight_xap_url : '{/literal}{$_path}{literal}js/plupload.silverlight.xap'
	});

	// Client side form validation
	$('form').submit(function(e) {
        var uploader = $('#uploader').plupload('getUploader');

        // Files in queue upload them first
        if (uploader.files.length > 0) {
            // When all files are uploaded submit form
            uploader.bind('StateChanged', function() {
                if (uploader.files.length === (uploader.total.uploaded + uploader.total.failed)) {
                    $('form')[0].submit();
                }
            });
                
            uploader.start();
        } else
            alert('You must at least upload one file.');

        return false;
    });
	 

});
{/literal}
</script>
